package lzzy.edu.cn.demothymeleaf.controller;

import org.springframework.stereotype.Controller; // 导入控制器注解
import org.springframework.ui.Model; // 导入模型类，用于传递数据
import org.springframework.web.bind.annotation.ControllerAdvice; // 导入控制器增强注解
import org.springframework.web.bind.annotation.ExceptionHandler; // 导入异常处理注解

@ControllerAdvice
public class GlobalExceptionController {
    @ExceptionHandler(Exception.class)
    public String myError(Exception e, Model model) {
        model.addAttribute("msg", e.getMessage());
        return "myerror";
    }
}